home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / strategy / vga_card.000 / vga_cardgames-1.3.1.tar / vga_cardgames / key.c < prev    next >
C/C++ Source or Header  |  1995-02-26  |  825b  |  43 lines

  1. /*
  2.  * Keyboard handling
  3.  *
  4.  * Copyright (C) Evan Harris, 1994, 1995.
  5.  *
  6.  * Permission is granted to freely redistribute and modify this code,
  7.  * providing the author(s) get credit for having written it.
  8.  */
  9.  
  10. #include <vga.h>
  11. #include "key.h"
  12.  
  13. /*
  14.  * We probably should use the svgalib keyboard_() functions, but the warnings
  15.  * scared me.  8-)
  16.  */
  17.  
  18. int
  19. key_getkey()
  20. {
  21.     int key;
  22.  
  23.     if ((key = vga_getkey()) != 0x1b) {
  24.     return key;        /* not ESC */
  25.     }
  26.     if ((key = vga_getkey()) != '[') {
  27.     return 0x1b;        /* it was ESC */
  28.     }
  29.     switch (key = vga_getkey()) {
  30.       case 'A':
  31.     return KEY_CURSORUP;    /* up */
  32.       case 'B':
  33.     return KEY_CURSORDOWN;    /* down */
  34.       case 'C':
  35.     return KEY_CURSORRIGHT;    /* right */
  36.       case 'D':
  37.     return KEY_CURSORLEFT;    /* left */
  38.       default:
  39.     return -1;        /* ignore */
  40.     break;
  41.     }
  42. }
  43.